<?php

include_once("core/controller.php");
include_once("core/versionHandler.php");
include_once("core/logs.php");

/**
 * @copyright inovia
 * @package oolime_manager 
 *
 */  
class homeMonitoring extends Controller{

  public function isLegitimate(){
    
    return true;
  }
  
  public function actions(){
    global $configLogDataBaseFile;
    global $configLogType;
    global $configLogFileName;
    
    $versionH=new VersionHandler("");
    $this->response->add($versionH->getMyVersion());
    
    $dateNode = $this->response->doc->createElement("date");
    $dateNode->appendChild($this->response->doc->createTextNode(date("d/m/Y G:i")));
    $this->response->add($dateNode);  
    
    if (file_exists($configLogDataBaseFile)) {
      $parentNode = $this->response->doc->createElement("logsDatabase");
      $entryNode = $this->response->doc->createElement("entry");
      
        $contentNode = $this->response->doc->createElement("name");
        $contentNode->appendChild($this->response->doc->createTextNode($configLogDataBaseFile));
        $entryNode->appendChild($contentNode); 
      
        $contentNode = $this->response->doc->createElement("date");
        $contentNode->appendChild($this->response->doc->createTextNode(date ("F d Y H:i:s", filemtime($configLogDataBaseFile))));
        $entryNode->appendChild($contentNode); 
        
        $parentNode->appendChild($entryNode);
      $this->response->add($parentNode); 
    }
    
    if (file_exists($configLogFileName)) {
      $parentNode = $this->response->doc->createElement("logsOolime");
      $entryNode = $this->response->doc->createElement("entry");
      
        $contentNode = $this->response->doc->createElement("name");
        $contentNode->appendChild($this->response->doc->createTextNode($configLogFileName));
        $entryNode->appendChild($contentNode); 
      
        $contentNode = $this->response->doc->createElement("date");
        $contentNode->appendChild($this->response->doc->createTextNode(date ("F d Y H:i:s", filemtime($configLogFileName))));
        $entryNode->appendChild($contentNode); 
        
        $parentNode->appendChild($entryNode);
      $this->response->add($parentNode); 
    }

    $this->response->setXSLT("views/manager/monitoring.xsl");
  }
  
  public function defaultActions(){
    
    $this->response->setXSLT("views/login.xsl");
  }



}

?>
